home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / ViewIt™ 2.24 Shareware / C Demo Projects / THINK C 6.0 Demos / vDemoLC.c < prev    next >
Text File  |  1994-04-09  |  4KB  |  114 lines

  1. /* ViewIt 2.2 Demonstration Program */
  2. /* ©FaceWare 1991-93.  All Rights Reserved. */
  3.  
  4. #include "string.h"
  5. #include "FaceStorLC.h"
  6. extern struct FaceRec fRec;
  7.  
  8. short helpShown;
  9. struct {
  10.     short        myInteger;
  11.     float        myReal;
  12.     char        myString[100];
  13.     long        myFlags;
  14.     } myRec;
  15. short myList;
  16. long oldTicks,newTicks;
  17. float theReal,delta;
  18.  
  19. pascal void fJumpIt(Ptr thePtr) = {0x2257,0x2051,0x4E90};
  20.  
  21. pascal void OverProc(Ptr thePtr) {
  22.     if (fRec.uCommand == 264)            /* a key down message? */
  23.         if (fRec.uParam[0] == 32)        /* SPACE key pressed? */
  24.             fRec.uParam[0] = 95;            /* convert to UNDERLINE */
  25.     fJumpIt(thePtr);}                            /* pass message to driver */
  26.  
  27. void main()
  28. {
  29.     myRec.myInteger = 0;
  30.     myRec.myReal = 6.2;
  31.     strcpy(myRec.myString,"Hello");
  32.     myRec.myFlags = 10;
  33.     myList = 2;
  34.     oldTicks = 0;
  35.     theReal = 6.0;
  36.  
  37. /* Initialize FaceIt */
  38.     strcpy(fRec.uName, "vDemo.Rsrc");
  39.     FaceIt(0,DoInit,0,0,0,0);
  40.  
  41. /* Open Modeless Window using FWND 1000 */
  42.     FaceIt(0,NewWnd,1000,1,0,0);
  43.  
  44.     for (;;) {
  45.         FaceIt(0,DoLoop,0,0,0,0);
  46. /* Standard "About" Menu Item Selection */
  47.         if ((fRec.uMenuID == 101L) && (fRec.uMenuItem == 1L)) {
  48.             strcpy(fRec.uString, "Demonstration of the use of ViewIt\rwindows in a FaceIt-based program.");
  49.             FaceIt(0,ShoStr,3,12,(1 + (409 * 65536)),0);
  50.             }
  51. /* Hit in Modeless Window's "Open Modal" Button */
  52.         else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 2L)) {
  53.             FaceIt(0,NewWnd,1001,0,0,0);                /* Open Modal Window */
  54.             for (;;) {
  55.                 FaceIt(0,MdlWnd,1001,0,0,0);            /* Process Modal Events */
  56.                 if (fRec.wcHit == -1L)                        /* Hit in Close Box */
  57.                     break;
  58.                 else if (fRec.wcHit == 1L) {            /* Hit in "Open Nested" Button */
  59.                     FaceIt(0,NewWnd,1002,0,0,(long)&myRec);            /* Open Nested Modal */
  60.                     FaceIt(0,GetCtl,1002,0,3,3);                                /* Link Scrollable List */
  61.                     FaceIt(0,LnkCtl,(long)fRec.cControl,(long)&myList,2,0);
  62.                     FaceIt(0,GetCtl,1002,0,2,3);                                /* Set Override Proc */
  63.                     FaceIt(0,OvrCtl,(long)fRec.cControl,(long)&OverProc,0,0);
  64.                     FaceIt(0,SetVal,1002,0,0,0);                                /* Set Linked Values */
  65.                     helpShown = false;
  66.                     for (;;) {
  67.                         FaceIt(0,MdlWnd,1002,-2,0,0);                            /* Process Modal Events */
  68.                         if (fRec.uMenuID == 0L) {                                    /* No Message */
  69.                             newTicks = TickCount();
  70.                             if (newTicks > oldTicks + 60) {
  71.                                 oldTicks = newTicks;
  72.                                 FaceIt(0,GetCtl,1002,0,2,8);
  73.                                 SetCtlValue(fRec.cControl,(fRec.cValue % 4) + 1);
  74.                                 }
  75.                             }
  76.                         else if (fRec.wvHit == 1L) {                            /* Hit in View #1 */
  77.                             if (fRec.wcHit == 1L)                                        /* Hit in "OK" Button */
  78.                                 break;
  79.                             else if (fRec.wcHit == 2L) {                        /* Hit in "Show/Hide" */
  80.                                 if (helpShown == true) {
  81.                                     FaceIt(0,ShoCtl,0,0,-3,2);                    /* Hide v3, Show v2 */
  82.                                     helpShown = false;}
  83.                                 else {
  84.                                     FaceIt(0,ShoCtl,0,0,-2,3);                    /* Hide v2, Show v3 */
  85.                                     helpShown = true;}
  86.                                 }
  87.                             }
  88.                         else if (fRec.wvHit == 2L)                                /* Hit in View #2 */
  89.                             if ((fRec.wcHit == 6L)||(fRec.wcHit == 7L)) { /* Up/Down Arrow */
  90.                                 FaceIt(0,GetCtl,1002,0,2,(long)fRec.wcHit);
  91.                                 delta = 0.001 * (fRec.cMin - 2);
  92.                                 myRec.myReal = myRec.myReal + delta;
  93.                                 FaceIt(0,SetVal,1002,0,2,2);
  94.                                 Delay(5,&fRec.uI4);
  95.                                 }
  96.                         }
  97.                     FaceIt(0,GetVal,1002,0,0,0);                                /* Get Linked Values */
  98.                     FaceIt(0,EndWnd,1002,0,0,0);                                /* Close Nested Modal */
  99.                     }
  100.                 }
  101.             FaceIt(0,EndWnd,1001,0,0,0);                /* Close Modal Window */
  102.           }
  103. /* Hit in Modeless Window's "Why ViewIt?" Button */
  104.         else if ((fRec.uMenuID == 1000L) && (fRec.wcHit == 3L)) {
  105.             FaceIt(0,NewWnd,1003,0,0,(long)&theReal);
  106.             FaceIt(0,SetVal,1003,0,0,0);
  107.             for (;;) {
  108.                 FaceIt(0,MdlWnd,1003,0,0,0);
  109.                 if (fRec.wcHit == 1L) break;}
  110.             FaceIt(0,GetVal,1003,0,0,0);
  111.             FaceIt(0,EndWnd,1003,0,0,0);
  112.             }
  113.         }
  114. }